package F.树;

public class _226_翻转二叉树 {

    /**自解
     * 递归法 采取后续遍历 如果root 返回null
     * 否则 左右交换
     * @param root
     * @return
     */
    public TreeNode invertTree(TreeNode root) {
        if (root==null){
            return root;
        }
        TreeNode left = invertTree(root.left);
        TreeNode right = invertTree(root.right);


        TreeNode temp = left;
        root.left = right;
        root.right = temp;

        return root;


    }


}
